package com.sc.study.clazz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.sc.study.clazz.domain.ScClazzSubjectTeacher;
import com.sc.study.foundation.domain.ScSubjectTeacher;
import com.sc.study.foundation.mapper.ScSubjectTeacherMapper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sc.common.annotation.Log;
import com.sc.common.core.controller.BaseController;
import com.sc.common.core.domain.AjaxResult;
import com.sc.common.enums.BusinessType;
import com.sc.study.clazz.domain.ScClazzSubject;
import com.sc.study.clazz.service.IScClazzSubjectService;
import com.sc.common.utils.poi.ExcelUtil;
import com.sc.common.core.page.TableDataInfo;

/**
 * 班级科目Controller
 * 
 * @author sc
 * @date 2022-02-27
 */
@RestController
@RequestMapping("/study/clazzsubject")
public class ScClazzSubjectController extends BaseController
{
    @Autowired
    private IScClazzSubjectService scClazzSubjectService;

    /**
     * 查询班级科目列表包含科目、班级
     */
    @PreAuthorize("@ss.hasPermi('study:clazzsubject:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScClazzSubject scClazzSubject)
    {
        startPage();
        List<ScClazzSubject> list = scClazzSubjectService.selectScClazzSubjectList(scClazzSubject);
        return getDataTable(list);
    }

    /**
     * 导出班级科目列表
     */
    @PreAuthorize("@ss.hasPermi('study:clazzsubject:export')")
    @Log(title = "班级科目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScClazzSubject scClazzSubject)
    {
        List<ScClazzSubject> list = scClazzSubjectService.selectScClazzSubjectList(scClazzSubject);
        ExcelUtil<ScClazzSubject> util = new ExcelUtil<ScClazzSubject>(ScClazzSubject.class);
        util.exportExcel(response, list, "班级科目数据");
    }

    /**
     * 获取班级科目详细信息
     */
    @PreAuthorize("@ss.hasPermi('study:clazzsubject:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(scClazzSubjectService.selectScClazzSubjectById(id));
    }

    /**
     * 新增班级科目
     */
    @PreAuthorize("@ss.hasPermi('study:clazzsubject:add')")
    @Log(title = "班级科目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScClazzSubject scClazzSubject)
    {
        return toAjax(scClazzSubjectService.insertScClazzSubject(scClazzSubject));
    }

    /**
     * 修改班级科目
     */
    @PreAuthorize("@ss.hasPermi('study:clazzsubject:edit')")
    @Log(title = "班级科目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScClazzSubject scClazzSubject)
    {
        return toAjax(scClazzSubjectService.updateScClazzSubject(scClazzSubject));
    }

    /**
     * 删除班级科目
     */
    @PreAuthorize("@ss.hasPermi('study:clazzsubject:remove')")
    @Log(title = "班级科目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scClazzSubjectService.deleteScClazzSubjectByIds(ids));
    }

}
